<?php
class Cl_ZipCode extends WdkClass 
{
	protected
		/******************************************************/
		//	원본 테이블 정보
		/******************************************************/
		$zipcode_seq		= 0		,	//	
		$zipcode_code		= ''	,	//	
		$zipcode_sido		= ''	,	//	
		$zipcode_gugun		= ''	,	//	
		$zipcode_dong		= ''	,	//	
		$zipcode_ri			= ''	,	//	
		$zipcode_building	= ''	,	//	
		$zipcode_bunji		= ''	;	//	
		/******************************************************/
		//	추가 정보
		/******************************************************/
	
	/**
	 * 	
	 */
	function __construct()
	{
		parent::__construct();
		self::getDbo();
	}
	
	/**
	 *	
	 */
	public function __init($data)
	{
		parent::__init($data);
		self::dformat();
	}
	
	/**
	 *	
	 */
	public function load($zipcode_seq)
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		self::__init($dbo->cLoad($zipcode_seq));
	}
	
	/**
	 *	
	 */
	public function dformat()
	{
	
	}
	
	/**
	 * 
	 */
	public function autoUpdate($log='')
	{
		if((int)$this->zipcode_seq > 0)
		{
			$this->update($log);
		}
		else
		{
			$this->insert($log);
		}
	}
	
	/**
	 *	
	 */
	public function insert($log='Insert')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		
		$data = array(	'zipcode_code'		=>	$this->zipcode_code,
						'zipcode_sido'		=>	$this->zipcode_sido,
						'zipcode_gugun'		=>	$this->zipcode_gugun,
						'zipcode_dong'		=>	$this->zipcode_dong,
						'zipcode_ri'		=>	$this->zipcode_ri,
						'zipcode_building'	=>	$this->zipcode_building,
						'zipcode_bunji'		=>	$this->zipcode_bunji
					);
		$this->zipcode_seq = $dbo->insert($data);
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function update($log='update')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/

		$data = array(	'zipcode_code'		=>	$this->zipcode_code,
						'zipcode_sido'		=>	$this->zipcode_sido,
						'zipcode_gugun'		=>	$this->zipcode_gugun,
						'zipcode_dong'		=>	$this->zipcode_dong,
						'zipcode_ri'		=>	$this->zipcode_ri,
						'zipcode_building'	=>	$this->zipcode_building,
						'zipcode_bunji'		=>	$this->zipcode_bunji
					);
		$dbo->update($data, array("zipcode_seq = ".$this->zipcode_seq));
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function delete($log='delete')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		$dbo->pdelete(array("zipcode_seq = ".$this->zipcode_seq));
		$this->backup($log);
	}
	
	/**
	 *	
	 */
	private function backup($log='')
	{
// 		/*------------------------------------------------------------*/
// 		$dbo = self::getDbo();
// 		/*------------------------------------------------------------*/
// 		$dbo->log($this->user_seq, $log, $this->backup_data);
	}
	
	/**
	 * 
	 */
	public function getDbo()
	{
		return Wdk::model(substr(__CLASS__, 3));
	}
}